package leetcode.l0527;

import java.util.ArrayList;

/**
 * @author Retain
 * @date 2021/5/27 10:31
 */
public class Easy_最小栈_155 {
}
class MinStack {
    private ArrayList<Integer> list;
    /** initialize your data structure here. */
    public MinStack() {
        list = new ArrayList<>();
    }

    public void push(int x) {
        list.add(x);
    }

    public void pop() {
        if (list.size() != 0) {
            list.remove(list.size() - 1);
        }

    }

    public int top() {
        if (list.size() != 0) {
            return list.get(list.size() - 1);
        }
        return 0;
    }

    public int getMin() {
        return list.stream().min(Integer::compareTo).orElseThrow();
    }
}
